<template>
	<!--代理端小区管理-->
	<view class="community">
		<view class="head_bg">
			<view class="cu-bar search">
				<view class="search-form bg-white" style="border-radius:50rpx;">
					<text class="cuIcon-search"></text>
					<input type="text" placeholder="" confirm-type="search" @input="getinputvalue"></input>
					 <view @tap="search" class="text-right margin-right-sm text-lg">搜索</view>
				</view>
			</view>
		</view>
		<view class="big_box" v-for="(info,index) in list" :key="index">
			<view class="big_box_inner">
				<view class="big_inner_one" style="border-radius:20rpx 20rpx 0 0 ;">
					<!-- @tap="toDetail(info.residential_quarters_guid)" -->
					<view>
						<view class="community_title_inner">
							<view class="community_title">{{info.residential_quarters_name}}</view>
							<view class="community_time text-red">
							<text  style="vertical-align: middle;margin-top:20rpx;">
							{{info.model_ratio}}%
							</text>
							<!-- <image  src="../../../common/img/delxq.png" style="width:99rpx;height:85rpx;vertical-align: middle"></image> -->
							</view>
						</view>
						<!-- <view class="uni_rogress">
							<uniProgress style="margin-left: 30rpx;" :percentage="60" explain="" percentBackground="#007aff"></uniProgress>
						</view> -->
						<view class="community_count" style="border:none;">
							<view class="community_count_inner">
								<view class="community_count_inner_number">{{info.device_total}}</view>
								<view class="community_count_inner_text">插座个数(个)</view>
							</view>
							<view class="detail_br" style="border-left: 2rpx solid #EDEDED;position: relative;top:10rpx;heigth:60rpx;"></view>
							<view class="community_count_inner">
								<view class="community_count_inner_number">{{info.device_normal_total}}</view>
								<view class="community_count_inner_text">正常个数(个)</view>
							</view>
							<view class="detail_br" style="border-left: 2rpx solid #EDEDED;position: relative;top:10rpx;heigth:60rpx;"></view>
							<view class="community_count_inner">
								<view class="community_count_inner_number" >{{info.device_fault_total}}</view>
								<view class="community_count_inner_text">故障个数(个)</view>
							</view>
						</view>
						<view class="community_count">
							<view class="community_count_inner">
								<view class="community_count_inner_number">{{info.device_online_total}}</view>
								<view class="community_count_inner_text">在线个数</view>
							</view>
							<view class="detail_br" style="border-left: 2rpx solid #EDEDED;position: relative;top:10rpx;heigth:60rpx;"></view>
							<view class="community_count_inner">
								<view class="community_count_inner_number">{{info.device_off_total}}</view>
								<view class="community_count_inner_text">离线个数</view>
							</view>
							<view class="detail_br" style="border-left: 2rpx solid #EDEDED;position: relative;top:10rpx;heigth:60rpx;"></view>
							<view class="community_count_inner">
								<view class="community_count_inner_number" >{{info.device_user_total}}</view>
								<view class="community_count_inner_text">正在使用</view>
							</view>
						</view>
					</view>
					<view class="community_address">
						<view class="community_address_left">
							<image class="community_address_iconl" src="../../../common/img/dizhi_hui.png" mode=""></image>
							<view class="community_address_text">{{info.residential_quarters_address}}</view>
						</view>
					</view>
				</view>
				<view class="operating_box_inner bg-white" style="padding:18rpx;border-radius:0 0 20rpx 20rpx;box-shadow: 0px 1px 10px 0px rgba(0, 0, 0, 0.13);">
					<view class="money_details_inner money_details_inner1" @click="todayfc(info)" style="margin-top:20rpx;font-size: 32rpx;">
						<view class="money_details_text" style="color: #666666;">日分成</view>
					</view>
					<view class="detail_br" style="border-left: 2rpx solid #EDEDED;position: relative;top:10rpx;heigth:60rpx;"></view>
					<view class="money_details_inner money_details_inner1" @click="tomoneyfc(info)" style="margin-top:20rpx;font-size: 32rpx;">
						<view class="money_details_text" style="color: #666666;">月分成</view>
					</view>
					<view class="detail_br" style="border-left: 2rpx solid #EDEDED;position: relative;top:10rpx;heigth:60rpx;"></view>
					<view class="money_details_inner money_details_inner1" @click="toorder(info)" style="margin-top:20rpx;font-size: 32rpx;">
						<view class="money_details_text" style="color: #666666;">订单记录</view>
					</view>
				</view>
			</view>
			<view style="height:20rpx;"></view>
		</view>
		<view style="height:100rpx;"></view>
		<view v-if="list.length==0" class="margin-top-lg text-center">
			<image src='../../../common/img/no_data.png' style="width:275rpx;height:312rpx;"></image>
		</view>
		<view v-if="list.length>0" class="text-black text-df text-center bg-white padding-sm padding-left-lg be-gray">
			{{loadingTxt}} 共({{list.length}}条记录)
		</view>
		
	</view>
</template>
<script>
	let page=1,timer=null
	export default {
		data() {
			return {
				list:[],
				loadingTxt:'加载更多',
				totle:0,
				name:'',
				info:{
					residential_quarters_guid:'',	//字符串	小区标识
					residential_quarters_name:'',//	字符串	小区名称
					residential_quarters_address:'',//	字符串	小区地址
					device_total:0,//	整型	插座个数
					device_normal_total:0,//	整型	正常个数
					device_fault_total:0,//	整型	故障个数
					device_online_total:0,//	整型	在线个数
					device_off_total:0,//	整型	离线个数
					device_user_total:0,//	整型	正常使用个数
					sharing_mode:'1',//	字符串	分成模式  1毛利 2纯利
					sharing_ratio:''//	字符串	分成比例
			},
		  }
		},
		onShow() {
			page=1;
			this.getdata(this.name);
		},
		methods:{
			search(){
				this.getdata(this.name);
				this.name='';
			},
			getdata(na){
				let that=this;
				that.http.tokenreq({
					url: 'agent/v1/village',
					data: {
                    "pageindex":page,
					"village":na
					}
				}).then((res) => {
					let e=res.data;
					console.log(e);
					if(e.code==0 && e.success){
						this.list = e.rows;
						this.totle= e.total;
						page++;
					}else{
						uni.showModal({
							content:e.message,
							showCancel:false,
						})
					}
				})
				
			},
			getmorelist(){
				let that=this;
				this.loadingTxt='加载中'
				that.http.tokenreq({
					url: 'agent/v1/village',
					data: {
				    "pageindex":page,
					"village":this.name
					}
				}).then((res) => {
					uni.hideLoading();
					let e=res.data;
					if(e.code==0 && e.success){
						if(e.rows.length==0){
							that.loadingTxt="已经加载全部";
							return;
						}
						that.list=that.list.concat(e.rows);
						page++;
					}
				})
			},
			onReachBottom() {
				//阻止重复加载
				if(timer !== null){
					clearTimeout(timer)
				}
				timer=setTimeout(()=>this.getmorelist(),500)
			},	
			getinputvalue(e){
				this.name = e.detail.value
				//this.getdata(this.name);
			},
			todayfc(info){
				uni.navigateTo({
					url:'/pages/agent/dailyReport/dailyReport?item='+JSON.stringify(info)
				})
			},
			tomoneyfc(info){
				uni.navigateTo({
					url:'/pages/agent/monthReport/monthReport?item='+JSON.stringify(info)
				})
			},
			// 订单记录
			toorder(info){
				uni.navigateTo({
					url:'/pages/agent/communityList/order?guid='+info.residential_quarters_guid
				})
			},
		}
	}
</script>

<style>
	.community_time{
		color: red;
	}

</style>